package com.zhl.study.controller;

import com.zhl.study.service.OrderService;
import com.zhl.study.base.ResponseFactory;
import com.zhl.study.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description 日志链路追踪
 * @Author: z156940l@outlook.com
 * @className ApiController
 * @Date: 2023/3/21 21:55
 */
@Slf4j
@RestController
@RequestMapping("api/")
@Api(value = "日志链路追踪", tags = "日志链路追踪")
public class ApiController {

    @Autowired
    private OrderService orderService;

    @GetMapping(value = "/pay/{orderSn}")
    @ApiOperation(httpMethod = "GET", value = "pay")
    public Result<String> alipay(@PathVariable("orderSn") String orderSn) {
        log.info("我开始了！");
        String result = orderService.alipay(orderSn);
        log.info("我结束了！{}",result);
        return ResponseFactory.ok(result);
    }

    @GetMapping(value = "/insert")
    @ApiOperation(httpMethod = "GET", value = "insert")
    public Result<String> insert() throws InterruptedException {
        log.info("我开始了！");
        orderService.insert();
        log.info("结束了！");
        return ResponseFactory.ok("ok");
    }

}
